from fastapi import APIRouter, Depends
from schemas.baseResponse import *
from services.demoService import DemoService
from schemas.demoDto import DemoFormRequest, DemoListRequest

router = APIRouter(prefix="/demo", tags=["demo"])

# 查询列表
@router.get("/list")
def list(request: DemoListRequest = Depends(),service: DemoService = Depends()):
    return SuccessResponse( service.list(request))
# 新增
@router.post("/add")
async def add(request: DemoFormRequest, service: DemoService = Depends()):
    return SuccessResponse(await service.add(request))
# 修改
@router.put("/update")
async def update(request: DemoFormRequest, service: DemoService = Depends()):
    return SuccessResponse(await service.update(request))
# 删除
@router.delete("/delete/{id}")
async def delete(id: int, service: DemoService = Depends()):
    return SuccessResponse(await service.delete(id))
